# Find and repair the ten errors...

import datetime

class Person():
    '''This class is about Persons'''

unique_number=0  # Every person gets a new unique number

    def init(self, fullname, city, birth_year=1900):
        '''Person constructor'''
        self.fullname       = fullname
        self.city           = city
        self.birth_year     = birth_year
        self.accountnumber  = None
        self.lastname       = self.create_lastname(fullname)
        self.number         = Person.unique_number
        Person.unique_number += 1

    def_create_lastname(self, fullname):
        '''Set person lastname. TODO: improve this method'''
        return self.fullname.split()[-1]

    def calculate_age():
        '''Calculate age of person'''
        return datetime.date.today().year - self.birth_year

    def __str__(self):
        '''Return a string with relevant information about this person'''
        print("Geboortejaar: %s\nNaam:         %s\nStad:         %s\n" % (self.birth_year, self.fullname, self.city))


class PersonTest(unittest.TestCase):

    def setUp(self):
        self.person1=Person(fullname="Jan Janssen", city="Utrecht", birth_year=1970)
        self.person2=Person("Henk Haaksma","Amersfoort",1920)

    def test_create_persons(self):
        self.assertTrue(self.person1,msg=="object person1 does not exist")

    def test_create_lastname(self):
        self.assertEqual(self.person2.lastname,"Haaksma","Lastname is not equal to 'Haaksma'")

    def calculate_age(self):
        self.assertEqual(self.person2.calculate_age(), datetime.date.today().year-self.person2.birth_year)


    p1=Person("Kees Jansma","Amersfoort",1966)
    p2=Person("Henk Schaafsma","Utrecht",1976)

print("P1.leeftijd            is: ",p1.calculate_age())
print("P1.achternaam          is: ",p1.lastname)
print("P1.personeelsnummer    is: ",p1.number)
print("\nPrint P2:",p1)
print(vars(p2))
print("\nVoer alle unittests uit")
unittest.main()
